{layout name="public/layout" /}
		{include file='yxnavbar'}
{if $op == 'post'}
<div class="clearfix">
	<form class="form-horizontal form" id="form1" action="" method="post" enctype="multipart/form-data">
		<div class="panel panel-default">
			<div class="panel-heading">马甲信息：新增马甲会自动给粉丝处增加一条相关记录</div>
			<div class="panel-body">
				<div class="form-group" id="username" style="display: none;">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">*</span>Openid</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="openid" value="{$item['openid']}" class="form-control">
						<div class="help-block">注意：如果想要把钱真的发到马甲微信里，此处必须填真实的粉丝openid，不填则只显示发放成功，实际无真正交易</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span class="require">* </span>昵称</label>
					<div class="col-sm-8 col-xs-12">
						<input type="text" class="form-control" name="nickname" value="{$item['nickname']}">
						<div class="help-block">马甲粉丝昵称</div>
					</div>
				</div>	
				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span class="require">* </span>头像</label>
					<div class="col-sm-8 col-xs-12">
						{php echo view_form_field_image('avatar', $item['avatar']);}
						<div class="help-block">马甲粉丝头像</div>
					</div>
				</div>

				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span class="text-danger">*</span>马甲类型</label>
					<div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
						<label class="radio-inline">
							<input name="type" value="0" type="radio"> 普通马甲
						</label>
						<label class="radio-inline">
							<input name="type" value="1"type="radio"> 团员身份
						</label>
						<label class="radio-inline">
							<input name="type" value="2"type="radio"> 团长身份
						</label>
						<div class="help-block" style="color: red;">注意：如果是团员身份类型，需要在下方指定团长ID【参团管理里面查询】</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span class="require">* </span>团长ID</label>
					<div class="col-sm-8 col-xs-12">
						<input type="text" class="form-control" name="groupid" value="{$item['groupid']}">
						<div class="help-block" style="color: red;">如需给某个团长增加马甲团员使其拼团成功，可以在此设置，注意：马甲新增不会有模板消息通知</div>
					</div>
				</div>
				<div class="form-group">
                     <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span class="text-danger">*</span>状态</label>
                    	<div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
							<label class="radio-inline">
								<input name="status" value="0" {if $item['status']==0} checked="checked"{/if} type="radio"> 暂停
							</label>
							<label class="radio-inline">
								<input name="status" value="1" {if $item['status']==1} checked="checked"{/if} type="radio"> 启用
							</label>
						</div>
                </div> 
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input name="submit" id="submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
			<input type="hidden" name="__token__" value="{$Request.token}" />
		</div>
	</form>
</div>
<script type="text/javascript">

</script>
{else}
<div class="mian">
	<div class="panel panel-info">
		<div class="panel-heading">当前数量： {$total}</div>
		<div class="panel panel-default">
		<div class="panel-body">
			<form id="addform" action="./index.php" method="post" enctype="multipart/form-data">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="{$_P['m']}" />
				<input type="hidden" name="do" value="{$do}" />
				<input type="hidden" name="themeid" value="{$themeid}" />
				<input type="hidden" name="op" value="import" />
			    <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">Excel文件</label>
                    <div class="col-sm-2 col-xs-2">
                        <input type="file" class="form-control"  name="file">
                    </div>
                    <input type="submit" class="btn btn-primary" value="导入">
                </div> 

			</form> 
		</div>
	</div>
	</div>
	
	<form class="form-horizontal" action="" method="post">
		<div class="panel panel-default">
			<div class="panel-body table-responsive">
				<table class="table table-hover">
					<thead class="navbar-inner">
						<tr>
							<th>ID</th>
							<th>昵称</th>
							<th>头像</th>
							<th>团ID</th>
                            <th>身份</th>
							<th>启用</th>
							<th style="width:150px; text-align:right;">操作</th>
						</tr>
					</thead>
					<tbody>
						{loop $list $row}
						<tr>
						    <td><b>{$row['id']}</b></td>
							<td style="font-size: 10px;">{$row['nickname']}</td>
							<td><img src="{php echo tomedia($row['avatar']);}" width="28" style="bsection-radius: 3px;"></td>
							<td><b>{$row['groupid']}</b></td>
                            <td>
                                {if $row['type']==-1}
                                <span class="label label-success">马甲</span>
                                {elseif $row['type']==1}
                                <span class="label label-primary">团员</span>
                                {else}
                                <span class="label label-warning">团长</span>
                                {/if}
                            </td>
							<td>
								<input type="checkbox" name="status[]" data-id="{$row['id']}" value="{$row['status']}" class="hidden" {if intval($row['status'])==1} checked="checked" {/if}/>
							</td>
							<td style="text-align:right;">
							<a class="btn btn-success btn-sm"
							href="{php echo createWebUrl($do, array('op'=>'post','id'=>$row['id'],'themeid'=>$themeid));}"
							title="编辑设置"><i class="fa fa-edit"> </i></a>
								<a href="{php echo createWebUrl('fake', array('op' => 'delete', 'themeid'=>$themeid,'id' => $row['id']));}" class="btn btn-warning btn-sm" title="删除" data-toggle="tooltip" data-placement="top" onclick="if(!confirm('删除后将不可恢复，确定删除吗?')) return false;"><i class="fa fa-times"> </i></a>
							</td>
						</tr>
						{/loop}
					</tbody>
				</table>
			</div>
		</div>
		{$pager}
	</form>
</div>

<script type="text/javascript">
	$(function(){
		$('.app-preview').click(function(){
			return false;
		});
		require(['underscore', 'bootstrap.switch'], function() {
			$(":checkbox[name='status[]']").bootstrapSwitch();
			$(':checkbox').on('switchChange.bootstrapSwitch', function(e, state){
				$this = $(this);
				var id = $(this).data('id');
				var status = this.checked ? 1 : 0;
				$.post("{php echo createWebUrl('fake', array('op' => 'status','themeid'=>$themeid));}", {status:status,id: id}, function(resp){
					resp = $.parseJSON(resp);
					if(resp.message.errno != 0) {
						layer.msg('操作失败, 请稍后重试');
					} else {
						layer.msg('操作成功');
					}
				});
			});
		});
	});
</script>
{/if}
